package com.sc.nft.admin.controller;




import com.sc.nft.admin.request.IdRequest;
import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.entity.dto.MerchantAvailabilityDTO;
import com.sc.nft.entity.vo.SaasTaskTemplatePageVO;
import com.sc.nft.service.SaasTaskTemplateService;
import com.sc.nft.sup.PageRequest;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 任务基础表(SaasTaskTemplate)表控制层
 *
 * @author 王伟成
 * @since 2024-01-12 15:50:53
 */

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/saasTaskTemplate")
@Api(tags = "任务模板")
public class SaasTaskTemplateController {
    /**
     * 服务对象
     */
    private final SaasTaskTemplateService saasTaskTemplateService;

    @PostMapping(value = "/page", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "saas任务模板列表", notes = "saas任务模板列表", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public PageResult<SaasTaskTemplatePageVO> page(@RequestBody PageRequest pageRequest) {
        return PageResult.success(saasTaskTemplateService.page(pageRequest));
    }

    @PostMapping(value = "/onOff", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "开关", notes = "开关", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result onOff(@RequestBody IdRequest idRequest) {
        saasTaskTemplateService.onOff(idRequest.getId());
        return Result.success();
    }


    @PostMapping(value = "/merchantAvailability", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "商户可用", notes = "商户可用", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result merchantAvailability(@RequestBody MerchantAvailabilityDTO merchantAvailabilityDTO) {
        saasTaskTemplateService.merchantAvailability(merchantAvailabilityDTO);
        return Result.success();
    }
}
